package com.atguigu.queue;

/**
 * @author shkstart
 * @create 2021-09-27 9:33
 */
/**
 *@Description:
 */


import java.util.concurrent.TimeUnit;

public class Test {

    public static void main(String[] args) {
        //开门
        System.out.println("开门接客啦！");
        boolean flag = true;
        CustomerQuene.getCustomerQuene();
        long a = System.currentTimeMillis();
        int servantNum = 10;
        for (int i = 0; i < servantNum; i++) {
            ServantThread thread = new ServantThread("服务台" + i);
            thread.start();
        }
        while (flag) {
            long b = System.currentTimeMillis();
            if (b - a > 1 * 60 * 1000 && flag) {
                //关门
                flag = false;
                CustomerQuene.getCustomerQuene().close();
                System.out.println("关门不接客啦！");
            }
            System.out.println("系统运行时间：" + (b -a) + "ms");
            System.out.println("系统空闲时间：" + ((b -a) * servantNum - ServantThread.getSumServeTime()));
            ServantThread.print();
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

}
